/*
 * Copyright 2010 Gaurav Saxena
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 */
package com.gwtstructs.gwt.client.widgets.list;

import com.google.gwt.dom.client.Document;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.ui.Widget;
import com.gwtstructs.gwt.client.widgets.list.BulletListPanel.BULLET_STYLE_TYPE;

public class NumberedListPanel extends ListPanel {
	public static enum NUMBER_STYLE_TYPE {
		ARMENIAN("armenian"),
		INTEGER("decimal"),
		INTEGER_LEADING_ZERO("decimal-leading-zero"),
		GEORGIAN("georgian"),
		ALPHABETICAL_LOWERCASE("lower-alpha"),
		GREEK_LOWERCASE("lower-greek"),
		ROMAN_LOWERCASE("lower-roman"),
		ALPHABETICAL_UPPERCASE("upper-alpha"),
		ROMAN_UPPERCASE("upper-roman"),
		NONE("none");
		private String styleType;
		public String toString() {
			return styleType;
		}
		NUMBER_STYLE_TYPE(String styleType) {
			this.styleType = styleType;
		}
	};
	public NumberedListPanel() {
		super(Document.get().createOLElement());
	}
	public void setNumbersFontSize(int fontSize) {
		DOM.setStyleAttribute(getElement(), "fontSize", fontSize + "px");
	}
	public void setNumberFontColor(String htmlColor) {
		DOM.setStyleAttribute(getElement(), "color", htmlColor);
	}
	public void setNumberStyleType(NUMBER_STYLE_TYPE type) {
		DOM.setStyleAttribute(getElement(), "listStyleType", type.toString());
	}
	public void setBulletSize(Widget w, int bulletSize) {
		if(super.getWidgetIndex(w) > -1)
			DOM.setStyleAttribute((Element) w.getElement().getParentElement(), "fontSize", bulletSize + "px");
	}
	public void setBulletColor(Widget w, String htmlColor) {
		if(super.getWidgetIndex(w) > -1)
			DOM.setStyleAttribute((Element) w.getElement().getParentElement(), "color", htmlColor);
	}
	public void setBulletImageUrl(Widget w, String url) {
		if(super.getWidgetIndex(w) > -1) {
			DOM.setStyleAttribute((Element) w.getElement().getParentElement(), "listStyleImage", "url(\"" + url + "\")");
			setBulletStyleType(w, BULLET_STYLE_TYPE.NONE);
		}
	}
	public void setBulletStyleType(Widget w, BULLET_STYLE_TYPE type) {
		if(super.getWidgetIndex(w) > -1)
			DOM.setStyleAttribute((Element) w.getElement().getParentElement(), "listStyleType", type.toString());
	}
}